package IOperation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-02
 * Time: 20:16
 */
public class BorrowOperation implements Operation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入要借阅的书名:");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        int size=bookList.getUseSize();
        for (int i = 0; i < size; i++) {
             Book book=bookList.getBook(i);
             if(book.getName().equals(name)){
             book.setBorrowed(true);
                 System.out.println("借阅成功");
             return;
             }
        }
        System.out.println("该书不存在");
    }
}
